// generating config files for single-crate mode
// Created: Aug. 23, 2023 by SUN Yazhou, asia.rabbit@163.com

#include "Single.h"
#include "LN.h"

Single::Single(const YAML::Node &n) : PN(n, CRATE_SINGLE){}

Single::~Single(){}

void Single::Ln(){
  LN *ds0 = data_save(0), *sc1 = sys_console_gui(1);
  // data stream //
  LN *ri2 = reduce_index(2, DATA);
  *ri2 >> *ds0;
  // cmd stream //
  LN *mi3 = map_index(3, CMD);
  *sc1 >> *mi3;
  // status stream //
  LN *ri4 = reduce_index(4, STA);
  *ri4 >> *sc1;
  // slave trigger
  LN *st6 = slave_trigger(5, fn["slave_trigger"].as<string>());
  *mi3 >> *st6; *st6 >> *ri4;

  int i = fLnMap.size();
  for(auto t : fn["dsi"]){
    LN *dsii = dsi(i++, t.as<string>());
    // data-cmd-sta: the order is mandatory
    *dsii >> *ri2; *mi3 >> *dsii; *dsii >> *ri4;
  } // end for over dsi
} // end memeber function Ln
